import request from '@/utils/request'

// 查询组织列表
export function list(query) {
  return request({
    url: '/system/org/page',
    method: 'get',
    params: query
  })
}

// 查询组织详细
export function get(roleId) {
  return request({
    url: '/system/org/' + roleId,
    method: 'get'
  })
}

// 获取组织树(当前用户)
export function fetchTree() {
  return request({
    url: '/system/org/tree',
    method: 'get'
  })
}

// 获取组织树(指定角色id)
export function fetchRoleOrg(data) {
  return request({
    url: '/system/org/tree/role',
    method: 'get',
    params: data
  })
}

// 指定角色授权组织树
export function grant(data) {
  return request({
    url: '/system/org/grant',
    method: 'post',
    data: data
  })
}

// 查询组织详细
export function listExcelHeader() {
  return request({
    url: '/system/org/excel/header',
    method: 'get'
  })
}

// 新增组织
export function add(data) {
  return request({
    url: '/system/org',
    method: 'post',
    data: data
  })
}

// 修改组织
export function update(data) {
  return request({
    url: '/system/org',
    method: 'patch',
    data: data
  })
}

// 导出组织
export function exportData(data, pageParam) {
  return request({
    responseType: 'blob',
    url: '/system/org/download/excel' + pageParam,
    method: 'post',
    data: data
  })
}

export function uploadData(data) {
  return request({
    url: '/system/org/upload/excel',
    method: 'post',
    data: data
  })
}

// 删除
export function deleteData(ids) {
  return request({
    url: '/system/org',
    method: 'delete',
    data: ids
  })
}
